package com.cloudbroker.bcs.common.event;

import org.springframework.context.ApplicationEvent;

public class BasicEvent extends ApplicationEvent {
    
    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 1L;
    
    protected String name;
    
    protected Object payload;
    
    protected boolean async;
    
    protected String[] penetratedContextKeys;
    
    public BasicEvent(Object source) {
        super(source);
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public Object getPayload() {
        return payload;
    }
    
    public void setPayload(Object payload) {
        this.payload = payload;
    }
    
    public boolean isAsync() {
        return async;
    }
    
    public void setAsync(boolean async) {
        this.async = async;
    }
    
    public String[] getPenetratedContextKeys() {
        return penetratedContextKeys;
    }
    
    public void setPenetratedContextKeys(String[] penetratedContextKeys) {
        this.penetratedContextKeys = penetratedContextKeys;
    }
    
    public String briefToString() {
        StringBuilder builder = new StringBuilder();
        builder.append(getClass().getSimpleName()).append(" [name=").append(name).append(", source=")
                .append(source).append(", async=").append(async).append(", timestamp=").append(getTimestamp())
                .append("]");
        return builder.toString();
    }
    
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append(getClass().getSimpleName()).append(" [name=").append(name).append(", source=")
                .append(source).append(", payload=").append(payload).append(", async=").append(async)
                .append(", penetratedContextKeys=").append(penetratedContextKeys).append(", timestamp=")
                .append(getTimestamp()).append("]");
        return builder.toString();
    }
    
}
